package fiuba.algo3.algoThieft.vista;

import java.awt.Button;
import java.awt.Choice;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import fiuba.algo3.algoThieft.controlador.Controlador;

public class VentanaOrden extends Ventana{

	
	private Label labelSexo = new Label("Sexo");
	private Label labelHobby = new Label("Hobby");
	private Label labelCabello = new Label("Cabello");
	private Label labelSenia = new Label("Senia");
	private Label labelVehiculo = new Label("Vehiculo");
	private Choice choiceSexo = new Choice();
	private Choice choiceHobby = new Choice();
	private Choice choiceCabello = new Choice();
	private Choice choiceSenia = new Choice();
	private Choice choiceVehiculo = new Choice();
	private Button botonBuscar = new Button("Buscar en la base de datos");
	private Button botonCancelar = new Button("Cancelar");
	
	public VentanaOrden(Controlador control) {
		this.frame = new Frame("Creando orden de arresto" ); //creando el marco
		this.frame.setLayout(new GridLayout(0, 1));
		
		this.llenarChoice();
		
				
		frame.add( "North" , new Label("Elije las caracteristicas" ));
		//agregando componentes
		Panel panelSexo = new Panel();
		panelSexo.add(labelSexo);
		panelSexo.add(choiceSexo);
		this.frame.add("Center", panelSexo);
		
		Panel panelHobby = new Panel();
		panelHobby.add(labelHobby);
		panelHobby.add(choiceHobby);
		this.frame.add("Center", panelHobby);
		
		Panel panelCabello = new Panel();
		panelCabello.add(labelCabello);
		panelCabello.add(choiceCabello);
		this.frame.add("Center", panelCabello);
		
		Panel panelSenia = new Panel();
		panelSenia.add(labelSenia);
		panelSenia.add(choiceSenia);
		this.frame.add("Center", panelSenia);
		
		Panel panelVehiculo = new Panel();
		panelVehiculo.add(labelVehiculo);
		panelVehiculo.add(choiceVehiculo);
		this.frame.add("Center", panelVehiculo);
						
		Panel panelOrden = new Panel();
		panelOrden.add(this.botonBuscar);
		panelOrden.add(this.botonCancelar);
		this.frame.add("South" , panelOrden);
		
		//agregando listener
		choiceSexo.addItemListener(control.getListenerChoiceSexo());
		choiceHobby.addItemListener(control.getListenerChoiceHobby());
		choiceCabello.addItemListener(control.getListenerChoiceCabello());
		choiceSenia.addItemListener(control.getListenerChoiceSenia());
		choiceVehiculo.addItemListener(control.getListenerChoiceVehiculo());
		
		botonBuscar.addActionListener(control.getListenerBotonBuscar());
		botonBuscar.addActionListener(this.getListenerBoton());
		botonCancelar.addActionListener(this.getListenerBoton());
		botonCancelar.addActionListener(control.getListenerBotonBuscar());
		//este no tiene un CloseListener porque
		//quiero que el usuario utilize el boton cancelar
		
		this.frame.setSize(300,400);  //seteo las dimensiones del marco
		
		
		new CentralizadorDeVentana().centrarVentana(this.frame);
	}

	private class EscuchaBoton implements ActionListener
	{	public void actionPerformed(ActionEvent e) 
		{
			frame.dispose();			
		}
	}

	private ActionListener getListenerBoton() {
		
		return new EscuchaBoton();
	}

	private void llenarChoice() {
		
		choiceSexo.add("");
		choiceSexo.add("Masculino");
		choiceSexo.add("Femenino");
		
		choiceHobby.add("");
		choiceHobby.add("Tenis");
		choiceHobby.add("Musica");
		choiceHobby.add("Alpinismo");
		choiceHobby.add("Paracaidismo");
		choiceHobby.add("Natacion");
		choiceHobby.add("Croquet");
		
		
		choiceCabello.add("");
		choiceCabello.add("Castanio");
		choiceCabello.add("Rubio");
		choiceCabello.add("Rojo");
		choiceCabello.add("Negro");
		
		choiceSenia.add("");
		choiceSenia.add("Anillo");
		choiceSenia.add("Tatuaje");
		choiceSenia.add("Cicratriz");
		choiceSenia.add("Joyas");
		
		choiceVehiculo.add("");
		choiceVehiculo.add("Moto");
		choiceVehiculo.add("Descapotable");
		choiceVehiculo.add("Limusina");
		choiceVehiculo.add("Deportivo");

		
	}

}
